package com.edevp.common.redis.util;

import java.util.Set;

/**
 * @author Blueeyedboy
 * @create 2022-07-06 3:19 PM
 **/
public class CacheUtil {
	public static int EXPIRE_IN_ONE_MINUTE = 60;
	public static int EXPIRE_IN_ONE_HOUR = 60*60;
	public static int EXPIRE_IN_ONE_DAY = 24*60*60;
	public static int EXPIRE_IN_ONE_MONTH = 24*60*60*30;


	public static <T> void put(String key,T obj,long expire){
		RedisUtil.getInstance().set(key,obj,expire);
	}

	public static <T> T get(String key){
		return RedisUtil.getInstance().get(key);
	}

	public static void del(String key){
		RedisUtil.getInstance().del(key);
	}

	public static int size(String pattern){
		Set<String> keys = RedisUtil.getInstance().getRedisTemplate().keys(pattern);
		return keys.size();
	}
}
